package notes.interview.saved;

public class T0002_singleton3 {

	// 单例模式，懒汉式，不直接创建，直到用时才创建
	private T0002_singleton3() {}
	
	private static T0002_singleton3 instance;
	
	public T0002_singleton3 getInstance() {
		if(instance == null) { // 这里容易在多线程时出问题，所以要加上同步
			synchronized (T0002_singleton3.class) {
				if(instance == null) {
					instance = new T0002_singleton3();
				}
			}
		}
		return instance;
	}
	
}
